import { defineStore } from 'pinia'
import { ref } from "vue"
import i18n from '@/i18n/index.js'

export const useSystemStore = defineStore(
    'system',
    () => {

        const lang = ref(i18n.global.locale.value)
        const setLang = (data) => {
            lang.value = data
            i18n.global.locale.value = data
        }

        return {
            lang,
            setLang
        }
    },
    // TODO: 持久化
    {
        persist: {
            storage: localStorage,
            paths: ['lang'],
            // 可选：单独关闭加密（如某个模块不需要加密）
            // encrypt: false 
        },
    },
)